package com.atguigu.base;


import java.util.concurrent.TimeUnit;

class Phone{
    public  synchronized void Email(){
        try {
            TimeUnit.SECONDS.sleep(4);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("发邮件");
    }
    public  synchronized void SMS(){
        System.out.println("发消息");
    }
    public void Hello(){
        System.out.println("你好");
    }
}
public class Lock8Demo {
    public static void main(String[] args) {
        Phone phone = new Phone();
        Phone phone1 = new Phone();
        new Thread(()-> {
            phone.Email();
            }, "李四").start();
        new Thread(()-> {
            phone.SMS();
            //phone.Hello();
            //phone1.SMS();
            }, "王五").start();
    }
}
